package dS.ProjectGPS.LeicaOWI;

import javax.microedition.lcdui.*;

public class FormOwiPOE extends Form implements FormOwi {

  OWIAgent owiAgent = null;

  TextField pointId = new TextField("Point Identifier", "", 16, TextField.ANY);
  TextField antHeight = new TextField("Antenna Height", "", 50,
                                      TextField.DECIMAL);
  ChoiceGroup antType = new ChoiceGroup("Antenna Type", ChoiceGroup.POPUP);

  public FormOwiPOE(OWIAgent o) {
    super("Point Occupation End");

    owiAgent = o;

    try {
      ndsInit();
    }
    catch (Exception ex) {
    }
  }

  public void ndsInit() throws Exception {
    append(pointId);
    append(antHeight);
    antType.append("Vertical", null);
    antType.append("Slope", null);
    append(antType);
  }

  public void update() {
    // N/A
  }

  public void save() {

    String msgId = "POE";

    // Setup SET parameters
    String[] outputs = {
                    msgId, pointId.getString(),
                    antHeight.getString(), "" + antType.getSelectedIndex(),
    };

    //Send message and update form if successful
    int ackCode = (owiAgent.set(msgId, OWI.setMessage(outputs)));
    Controller.showACKAlert(this, this, ackCode);
  }

}
